//
//  NavigationViewBootcamp.swift
//  SwiftUiExercise
//
//  Created by Mac on 2023/7/3.
//

import SwiftUI

struct NavigationViewBootcamp_31: View {
    var body: some View {
        NavigationView{
            ScrollView{
                
                NavigationLink("Hello World!",destination:MyOtherScreen())
              
                    Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
                    Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
                    Text("Hello, World!")
            }
            .navigationTitle("标题")
            .navigationBarTitleDisplayMode(.automatic)
            //.navigationBarHidden(true)
            .navigationBarItems(
                leading:
                    HStack {
                        Image(systemName: "person.fill")
                        Image(systemName: "flame.fill")
                    },
                trailing:
                    NavigationLink(
                        destination: Text("Destination"), label: {
                            Image(systemName: "gear")
                        }
                    )
            )
            
        }
     
    }
}

struct MyOtherScreen:View{
    
    @Environment(\.presentationMode) var presentationModel;
    
    var body: some View{
        ZStack{
            Color.green.edgesIgnoringSafeArea(.all)
                .navigationTitle("Green Screen")
            
            VStack {
                VStack(alignment: .leading) {
                    Button("BACK BUTTON") {
                        presentationModel.wrappedValue.dismiss()
                    }
                }
                NavigationLink("Click here!", destination:Text("3rd screen"))
            }
        }
    }
}

struct NavigationViewBootcamp_Previews: PreviewProvider {
    static var previews: some View {
        NavigationViewBootcamp_31()
    }
}
